﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;

namespace PyNet
{
    public partial class frmSmallConsole : Form
    {
        public delegate void LabelInvoke(string text);

        public frmSmallConsole()
        {
            InitializeComponent();
        }

        private void frmSmallConsole_Load(object sender, EventArgs e)
        {

        }

        public void Unshrink()
        {
            Program.GetConsole.Show();
            this.Hide();
        }

        private void frmSmallConsole_FormClosing(object sender, FormClosingEventArgs e)
        {
            Unshrink();
        }

        private void btnReturn_Click(object sender, EventArgs e)
        {
            Unshrink();
        }

        private void btnStart_Click(object sender, EventArgs e)
        {
            Program.GetServer.StartServerLoop();
        }

        private void btnStop_Click(object sender, EventArgs e)
        {
            Program.GetServer.StopServerLoop();
        }

        public void _SetLabel(string text)
        {
            lblStatus.Text = text;
        }

        public void SetLabel(string text)
        {
            if (this.InvokeRequired)
            {
                this.Invoke(new LabelInvoke(_SetLabel), text);
            }
            else
            {
                _SetLabel(text);
            }
        }
    }
}
